Conversation
… stayforge/Stayforge_Networks_Access#9) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
min_length=1,max_length=128, andpattern="^[a-zA-Z0-9]+$"constraints to theCardQuery.numberfield using Pydantic'sconstrRoot Cause
The
CardQuerymodel definednumberas a plainstrwith no length or format constraints. When an invalid string was submitted, it passed Pydantic validation, reached the Redis lookup in the card handler, failed to find a match, and returned a 404 "not found" error. This is misleading because the issue is invalid input, not a missing resource.Changes
CardQuery.numberfromstrtoconstr(min_length=1, max_length=128, pattern="^[a-zA-Z0-9]+$")insrc/card.pyCardModel.numberfield which already uses the same pattern constraintCloses stayforge/Stayforge_Networks_Access#9
Test plan
/card/with a card number longer than 128 characters — should return 422/card/with an empty card number — should return 422/card/with special characters in the number — should return 422/card/with a valid card number that doesn't exist — should still return 404/card/with a valid existing card number — should return 200 with card data🤖 Generated with Claude Code